package com.example.day16.ex04;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class HashMaoDemo {
    public static void main(String[] args) {
        HashMap<String,Student> hm= new HashMap<>();
        Student s1 = new Student("zhangsan",18);
        Student s2 = new Student("lisi",19);
        Student s3 = new Student("wangwu",20);
        hm.put("s1",s1);
        hm.put("s2",s2);
        hm.put("s3",s3);
        Set<String> keyset = hm.keySet();
        for (String key : keyset) {
            Student value = hm.get(key);
            System.out.println(key+":"+value.getName()+","+value.getAge());
        }
        System.out.println("--------------------------");
        Set<Map.Entry<String,Student>> entrySet = hm.entrySet();
        for (Map.Entry<String,Student> me : entrySet) {
            String key = me.getKey();
            Student value = me.getValue();
            System.out.println(key+":"+value.getName()+","+value.getAge());
        }
    }
}
